# -*- coding: utf-8 -*-
"""
Created on Tue May 28 17:20:21 2024

@author: 29865
"""

import pandas as pd
from sklearn.linear_model import LogisticRegression as LR

data = pd.read_excel('credit.xlsx')

# 划分数据为训练集和测试集
x_train = data.iloc[:600, :14].to_numpy()
y_train = data.iloc[:600, 14].to_numpy()
x_test = data.iloc[600:, :14].to_numpy()
y_test = data.iloc[600:, 14].to_numpy()


lr = LR()
lr.fit(x_train, y_train)
r = lr.score(x_train, y_train)  # 模型准确率（针对训练数据）
# 使用测试集x进行测试
R = lr.predict(x_test)

Z = R - y_test
Rs = len(Z[Z == 0])/len(Z)
